package com.dc.juc.example._6_threadLocal;

/**
 * Description: 请求持有
 * @author: gdc
 * @date: 2021/8/5
 * @version 1.0
 */
public class RequestHolder {

    /**
     * 线程持有信息，泛型
     */
    private final static ThreadLocal<Long> requestHolder = new ThreadLocal<>();

    /**
     * 设置存放值
     */
    public static void set(Long id) {
        requestHolder.set(id);
    }

    /**
     * 获取存放值
     */
    public static Long get() {
        return requestHolder.get();
    }

    /**
     * 删除 ThreadLocal
     */
    public static void remove() {
        requestHolder.remove();
    }
}
